import gtk.gdk
import StringIO
from gtk import *
from xml.sax.saxutils import escape
from os.path import basename
from urllib2 import url2pathname

THUMBNAILS_SIZE = 92
COVER = 0
KEY = 1
VALUE = 2
ID = 3
SEPARATOR = 4
BACKGROUND_COLOR = 5

def build_medialib(aidem):
    model = TreeStore(gtk.gdk.Pixbuf, str, str, int, bool, str)
    treeview = aidem.get_widget("treeview1")
    treeview.set_model(model)
    treeview.set_headers_visible(False)
    selection = treeview.get_selection()
    selection.set_mode(SELECTION_MULTIPLE)
    info = CellRendererText()
    cover = CellRendererPixbuf()
    column = TreeViewColumn("")
    column.pack_start(cover, expand=False)
    column.pack_start(info)
    column.set_attributes(cover, pixbuf=COVER, cell_background=BACKGROUND_COLOR)
    column.set_attributes(info, text=VALUE, cell_background=BACKGROUND_COLOR)
    column.set_visible(True)
    treeview.append_column(column)
